package com.heima.comment.controller;

import com.heima.comment.service.CommentService;
import com.heima.model.comment.dtos.CommentDTO;
import com.heima.model.comment.dtos.CommentLikeDTO;
import com.heima.model.comment.dtos.CommentSaveDTO;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/comment")
public class CommentServiceController {
    @Autowired
    private CommentService commentService;

    /**
     * 查询评论点赞信息
     *
     * @param commentLikeDto
     * @return
     */
    @PostMapping("/like")
    public ResponseResult like(@RequestBody CommentLikeDTO commentLikeDto) {
        return commentService.like(commentLikeDto);
    }

    /**
     * 发表评论
     *
     * @param commentSaveDTO
     * @return
     */
    @PostMapping("/save")
    public ResponseResult save(@RequestBody CommentSaveDTO commentSaveDTO) {
        return commentService.saveComment(commentSaveDTO);
    }

    /**
     * 查询评论列表
     *
     * @param commentDTO
     * @return
     */
    @PostMapping("/load")
    public ResponseResult load(@RequestBody CommentDTO commentDTO) {
        return commentService.load(commentDTO);
    }
}
